import java.util.Arrays;

/**
 * @ClassName LC2239
 * @Author ykx
 * @Date 2024/7/2 22:27
 * @Version 1.0
 */
public class LC2239 {
    public static void main(String[] args) {

    }

    public int findClosestNumber(int[] nums) {
        Arrays.sort(nums);
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] == 0) {
                return 0;
            }

            if (nums[i] * nums[i - 1] < 0) {
                return nums[i] + nums[i - 1] <= 0 ? nums[i] : nums[i - 1];
            }
        }
        return nums[0];
    }

}
